package com.example.demo.config.enums;

/**
 * @author yongen
 * @description: 维护topicTag和处理类的关系
 * @date 2022/2/9 3:04 PM
 */
public enum ConsumerBeanEnum {

  ADD_USER("T_DEMO_PROJECT:ADD_USER", "addUserHandler"),
  ADD_ORDER("T_DEMO_PROJECT:ADD_ORDER", "addOrderHandler"),
  ;
  /**
   * TOPIC:TAG 名称
   */
  private String topicTag;
  /**
   * Handler bean名称
   */
  private String beanName;

  public String getTopicTag() {
    return topicTag;
  }

  public void setTopicTag(String topicTag) {
    this.topicTag = topicTag;
  }

  public String getBeanName() {
    return beanName;
  }

  public void setBeanName(String beanName) {
    this.beanName = beanName;
  }

  ConsumerBeanEnum(String topicTag, String beanName) {
    this.topicTag = topicTag;
    this.beanName = beanName;
  }

  public static ConsumerBeanEnum getBeanByTopicTag(String topicTag) {
    for (ConsumerBeanEnum beanEnum : ConsumerBeanEnum.values()) {
      if (beanEnum.getTopicTag().equals(topicTag)) {
        return beanEnum;
      }
    }
    return null;
  }
}
